//
//  Router.swift
//  BCRouteKit
//
//  Created by chun.chen on 2021/8/23.
//  通用路由

import flutter_boost
import Foundation

public class Router {
    /// url 跳转
    /// - Parameter url: 检测是否前缀flutter.跳转flutter页面 否则本地页面
    public static func push(_ url: String) {
        if url.hasPrefix("flutter.") {
            let options = FlutterBoostRouteOptions()
            options.pageName = url
            FlutterBoost.instance()?.open(options)
        } else {
            BCRouter.shared().pushRoute(url)
        }
    }

    /// url 跳转
    /// - Parameters:
    ///   - url: 检测是否前缀flutter.跳转flutter页面 否则本地页面
    ///   - extData: 参数
    public static func push(_ url: String, extData: [String: Any]?) {
        if url.hasPrefix("flutter") {
            let options = FlutterBoostRouteOptions()
            options.pageName = url
            options.arguments = extData
            FlutterBoost.instance()?.open(options)
        } else {
            BCRouter.shared().pushRoute(url, extData: extData)
        }
    }
}
